package com.jqq.spring.mapper;

import com.jqq.spring.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.List;

/**
 * @author 姬倩倩
 * @date 2023-05-18
 */

public class UserMapperImpl extends SqlSessionDaoSupport implements UserMapper {

    @Override
    public List<User> getAllUser() {
        User user = new User(17, "qqq", "123", 18, "女", "77@qq.com");
        UserMapper mapper = getSqlSession().getMapper(UserMapper.class);

        mapper.addUser(user);

        mapper.deleteUser(17);
        return mapper.getAllUser();
    }

    @Override
    public int addUser(User user) {
        return getSqlSession().getMapper(UserMapper.class).addUser(user);
    }

    @Override
    public int deleteUser(int id) {
        return getSqlSession().getMapper(UserMapper.class).deleteUser(id);
    }
}

